package com.lollipop.synthential.java8.lambda.syntax.Exercise;


import com.lollipop.synthential.java8.lambda.syntax.data.Person;

import java.util.ArrayList;

/**
 * @Author: J.K
 * @Date: 2021-02-15 21:16
 * @Description:
 */
public class Excise1 {
    /**
     * 集合排序：
     * ArrayList<>
     *
     * @param args
     */
    public static void main(String[] args) {
        // 需求：已知在一个ArrayList中有若干个Person对象，将Person对象按年龄降序排序
        ArrayList<Person> list = new ArrayList<>();

        list.add(new Person("小明", 10));
        list.add(new Person("小蓝", 12));
        list.add(new Person("小红", 8));
        list.add(new Person("小黄", 16));
        list.add(new Person("小绿", 6));

        list.sort((o1, o2) -> o2.age - o1.age);
        System.out.println(list);
    }
}
